import 'package:dynamic_stock/const/const.dart';
import 'package:flutter/material.dart';

class AlertTool {
  
  // 提示确认框
  static Future<bool> showDeleteConfirmDialog(BuildContext context) {
    _currTextStyle(double fontsize, Color color, FontWeight fontWeight) {
      return TextStyle(
                        color: color,
                         fontSize: fontsize,
                         decoration: TextDecoration.none, fontWeight: fontWeight);
    }

    return showDialog<bool>(
      context: context,
      barrierDismissible: false,
      builder: (context) {
        return Center(
          child: Container(
            color: Colors.white,
            margin: const EdgeInsets.symmetric(horizontal: 50),
            child: SingleChildScrollView(
              child: Column(
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.fromLTRB(16, 24, 16, 8.5),
                    child: Text(
                      "提示",
                      style: _currTextStyle(18, Color(0xff333333), FontWeight.w500)
                    )
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 16, left: 16, right: 16),
                    child: Text(
                      "确定退出当前账号？",
                       style: _currTextStyle(14, Color(0xff333333), FontWeight.w400)
                      ),
                  ),
                  Divider(color: AppMainColor.dividerColor, height: 0.5,),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    children: <Widget>[
                      FlatButton(
                        child: Text("确定" ,style: _currTextStyle(18, AppMainColor.mainColor, FontWeight.w300),),
                        onPressed: (){
                          Navigator.of(context).pop(true);
                        },
                      ),
                      Container(width: 0.5 ,height: 50,color: AppMainColor.dividerColor),
                      FlatButton(
                        child: Text("取消",style: _currTextStyle(18, Color(0xff999999), FontWeight.w300),),
                        onPressed: (){
                          Navigator.of(context).pop();
                        },
                      )
                    ],
                  )
                ],
              ),
            ),
          ),
        );
      },
    );
  }

  static showLoadingDialog(BuildContext context, [String loadingText]) {
    showDialog(
      context: context,
      barrierDismissible: false, //点击遮罩不关闭对话框
      builder: (context) {
        return AlertDialog(
          content: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              CircularProgressIndicator(),
              Padding(
                padding: const EdgeInsets.only(top: 26.0),
                child: Text(loadingText != null ? loadingText : "正在加载，请稍后..."),
              )
            ],
          ),
        );
      },
    );
}
}